#include "LED.h"
TICK led;
void ledAllOff(void)
{
	LED_RED = LED_OFF;
	LED_GREEN = LED_OFF;
	LED_BLUE = LED_OFF;
	LED_WRITE = LED_OFF;
}
void ledAllOn(void)
{
	LED_RED = LED_ON;
	LED_GREEN = LED_ON;
	LED_BLUE = LED_ON;
	LED_WRITE = LED_ON;
}
void ledPortInit(void)
{
	
	GPIO_Init(GPIOC, GPIO_PIN_4, GPIO_MODE_OUT_PP_LOW_FAST);
	GPIO_Init(GPIOC, GPIO_PIN_5, GPIO_MODE_OUT_PP_LOW_FAST);
	GPIO_Init(GPIOC, GPIO_PIN_6, GPIO_MODE_OUT_PP_LOW_FAST);
	GPIO_Init(GPIOC, GPIO_PIN_7, GPIO_MODE_OUT_PP_LOW_FAST);
	
}

void ledDisplay(void)
{
	if((device.state.objValue==ObjValue_STATE_CLOSE)||(device.mode.objValue == ObjValue_MODE_SLEEP)\
	||(device.screen.objValue==ObjValue_Screen_Off)){
		ledAllOff();
		return;
	}
	if(flag.openDevice == 1){
		LED_WRITE = LED_ON;
		return;
	}
	if(device.pm25.objValue<75){
		LED_RED = LED_OFF;//100
		LED_GREEN = LED_OFF;//50-100 HUANG 
		LED_BLUE = LED_ON;//50
		LED_WRITE = LED_OFF;
		return;
	}
	if(device.pm25.objValue<150){
		LED_RED = LED_OFF;//100
		LED_GREEN = LED_ON;//50-100 HUANG 
		LED_BLUE = LED_OFF;//50
		LED_WRITE = LED_OFF;
		return;
	}
	LED_RED = LED_ON;//100
	LED_GREEN = LED_OFF;//50-100 HUANG 
	LED_BLUE = LED_OFF;//50
	LED_WRITE = LED_OFF;
}